<?php
/**
 * Gestion du contextSwitch CSV
 *
 * @package zfbook
 * @subpackage controller
 */
class Zfbook_Controller_ContextSwitch_Csv extends Zfbook_Controller_ContextSwitch_Abstract
{
    /**
     * Retourne le tableau de contexte du contextswitch
     *
     * @return array
     */
    public static function getContext()
    {
        return self::buildContext(__CLASS__, 'text/csv');
    }

    /**
     * Retourne le contenu des données à afficher
     *
     * @return
     */
    public static function getContent()
    {
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
        $reservations = (array) $viewRenderer->view->reservations->getIterator();
        $content      = Zfbook_Convert_Csv::getInstance()->convertFromArray($reservations);
        Zend_Controller_Front::getInstance()->getResponse()->setBody($content);
    }
}
